from GoogleNews import GoogleNews
import pandas
title = []
url = []
date = []
desc = []
img = []
googlenews = GoogleNews()
googlenews.search('covid-19')
print(googlenews.result())
for i in range(10000):
    googlenews.getpage(i)
    result = googlenews.result()
    for n in range(len(result)):
        news_dict = dict(result[n])
        news_title = news_dict['title']
        news_url = news_dict['link']
        news_date = news_dict['date']
        news_desc = news_dict['desc']
        news_img = news_dict['img']
        title.append(news_title)
        url.append(news_url)
        date.append(news_date)
        desc.append(news_desc)
        img.append(news_img)
    print(len(result))
dict = {'title':title,'url':url,'date':date,'desc':desc,'img':img}
alldata = pandas.DataFrame(dict)
alldata.to_csv('D://googlenews.csv',encoding='utf-8-sig')
print(alldata)